/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package apus.command.organization;

import apus.command.AbstractCommand;
import apus.entity.Organization;
import apus.entity.RealOrganization;
import apus.persistence.OrganizationDAO;
import apus.services.ServiceLocator;
import java.util.Arrays;
import java.util.List;

/**
 * The <code>AddOrganizationCommand</code> class represents command for adding 
 * new organization to database.
 * @author  Maxim Vasilevsky
 * @author  Roman Dyatkovsky
 * @since APUS v0.4
 * @see AbstractCommand
 */
public class AddOrganizationCommand extends AbstractCommand{
    private final static String PARAM_NAME = "Name";
    private final static String PARAM_ADDRESS = "Address";
    private final static String PARAM_BANKING_DETAILS = "Banking details";
    
    private final static String[] paramsNames = { PARAM_NAME, 
                                                  PARAM_ADDRESS,
                                                  PARAM_BANKING_DETAILS};
    
    public AddOrganizationCommand() {
        super("Add new organization");
    }

    @Override
    public void execute() {
        OrganizationDAO organizationDAO = ServiceLocator.getService(OrganizationDAO.class);
        Organization organization = new RealOrganization(params.get(PARAM_NAME),params.get(PARAM_ADDRESS));
        organization.setBankingDetails(params.get(PARAM_BANKING_DETAILS));
        organizationDAO.create(organization);
    }
    
    @Override
    public List<String> getParamNames() {
        return Arrays.asList(paramsNames);
    }
    
}
